package svc

import (
	"2210a/commod/commodapi/internal/config"
	"2210a/commod/commodapi/internal/middleware"
	"2210a/commod/commodrpc/commodrpcclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config              config.Config
	CommodEpc           commodrpcclient.Commodrpc
	UserTokenMiddleware rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:              c,
		CommodEpc:           commodrpcclient.NewCommodrpc(zrpc.MustNewClient(c.CommodEpc)),
		UserTokenMiddleware: middleware.NewUserTokenMiddleware().Handle,
	}
}
